package com.thtf.openguess.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


@Component
@Aspect
@Slf4j
public class Aop {
    @Pointcut("@annotation(com.thtf.openguess.aop.annotation.Time)")
    public void annotationPointcut() {
    }

    @Around("annotationPointcut()")
    public String serviceImplAop(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Long start = System.currentTimeMillis();
        //执行进程
        proceedingJoinPoint.proceed();
        Long end = System.currentTimeMillis();
        String times ="操作成功  耗费时间:"+ (end - start) / 1000 + " s";
        return times;
    }
}
